package com.caseProject.puremvc.mediator.view
{
	import com.caseProject.puremvc.mediator.events.MenuProjectEvent;
	
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	
	public class MenuProjectView extends Sprite
	{
		private var view:MenuPadraoSWC;
		
		public function MenuProjectView()
		{
			super();
			
			this.view = new MenuPadraoSWC();
			this.addChild(this.view);
			
			this.view.btnNovoDiagrama.enabled = false;
			
			this.view.btnAbrir.addEventListener(MouseEvent.CLICK, onAbrirClick);
			this.view.btnFechar.addEventListener(MouseEvent.CLICK, onFecharClick);
			this.view.btnNovoDiagrama.addEventListener(MouseEvent.CLICK, onNovoDiagramaClick);
			this.view.btnNovoProjeto.addEventListener(MouseEvent.CLICK, onNovoProjetoClick);
			this.view.btnSalvar.addEventListener(MouseEvent.CLICK, onSalvarClick);
		}
		
		protected function onSalvarClick(event:MouseEvent):void
		{
			this.dispatchEvent(new MenuProjectEvent(MenuProjectEvent.CLICK_SALVAR));
		}
		
		protected function onNovoProjetoClick(event:MouseEvent):void
		{
			this.dispatchEvent(new MenuProjectEvent(MenuProjectEvent.CLICK_NOVO_PROJETO));
			this.view.btnNovoDiagrama.enabled = true;
		}
		
		protected function onNovoDiagramaClick(event:MouseEvent):void
		{
			this.dispatchEvent(new MenuProjectEvent(MenuProjectEvent.CLICK_NOVO_DIAGRAMA));				
		}
		
		protected function onFecharClick(event:MouseEvent):void
		{
			this.dispatchEvent(new MenuProjectEvent(MenuProjectEvent.CLICK_FECHAR));
		}
		
		protected function onAbrirClick(event:MouseEvent):void
		{
			this.dispatchEvent(new MenuProjectEvent(MenuProjectEvent.CLICK_ABRIR));
			this.view.btnNovoDiagrama.enabled = true;
		}
	}
}